package com.rybbaby.tss.api.msgNotice;

import com.rybbaby.tss.core.bean.PageBean;
import com.rybbaby.tss.core.hqlsearch.HqlGenerateUtil;
import com.rybbaby.tss.core.utils.AppResponse;
import com.rybbaby.tss.core.web.controller.BaseController;
import com.rybbaby.tss.front.tssAppMsgNotice.entity.TssAppMsgNotice;
import com.rybbaby.tss.front.tssAppMsgNotice.service.ITssAppMsgNoticeService;
import org.hibernate.criterion.DetachedCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.MimeTypeUtils;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;


@RestController
@RequestMapping(value = "api/msgNotice", produces = MimeTypeUtils.APPLICATION_JSON_VALUE)
public class MsgNoticeApi extends BaseController {

    @Autowired
    private ITssAppMsgNoticeService tssAppMsgNoticeService;
    /**
    * @Title: 
    * @Package com.rybbaby.tss.api.msgNotice
    * @params: 
    * @returns: 
    * @Description: TODO
    * @author zhang
    * @date 2017/12/28 14:34
    * 
    */
    @CrossOrigin
    @RequestMapping(value = "tssAppMsgNoticeList", method = RequestMethod.POST)
    public String verifyPhoneRegistration(TssAppMsgNotice entity , PageBean paramPageBean) {
        String resMsg = "查询成功!";
        int resCode = 200;
        PageBean pageBean=new PageBean();
        try {
            entity.setIssue(2);
            Map<String, String[]> unLockMap = getParameterMap(request);
            DetachedCriteria dc = DetachedCriteria.forClass(TssAppMsgNotice.class);
            HqlGenerateUtil.fillDetachedCriteria(dc, entity, unLockMap);
            pageBean = tssAppMsgNoticeService.pageList(dc, paramPageBean.getPageNo(), paramPageBean.getPageSize());
        }catch (Exception e){
            resCode = 500;
            System.out.println("发送请求出现异常！" + e);
            e.printStackTrace();
        }
        return new AppResponse(resMsg, resCode,pageBean).jsonResponse(true);
    }
}
